package com.drug.controller;

import com.drug.domain.PurchaseOrder;
import com.drug.domain.Result;
import com.drug.domain.SdiDiInf;
import com.drug.mapper.SdiDiInfMapper;
import com.drug.mapper.SdiStatementMapper;
import com.drug.service.SdiDiInfService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class SdiDiInfController {

    @Autowired
    private SdiDiInfService sdiDiInfService;
    @Autowired
    private SdiDiInfMapper sdiDiInfMapper;

    /*
     * 修改(提交审核结果)
     * @param
     * @return
     */
    @RequestMapping(value="/SdiDiInfController/updateSubmit", produces = "application/json; charset=utf-8")
    @ResponseBody
    public Result updateSubmit(@RequestParam String[] sdiState, @RequestParam Integer[] sdiId){
        Result result = new Result();
        SdiDiInf sdiDiInf = new SdiDiInf();
        for(int i = 0;i<sdiState.length;i++){
            String str = sdiState[i];
            sdiDiInf.setSdiStatement(str);
            Integer integer = sdiId[i];
            sdiDiInf.setSdiId(integer);
            Integer integer1 = sdiDiInfMapper.selectDiId(integer);
            result = sdiDiInfService.updateSubmit(sdiDiInf);
            sdiDiInfService.updateSubmitDi(str,integer1);

        }
        return result;
    }
}
